import React, { Component } from 'react';
import Son1 from './Son1';
import Son2 from './Son2';

class Father extends Component {
  constructor() {
    super();
    this.state = {
      num: 18,
      data: 'hello'
    }
  }
  setData() {
    this.setState({
      data: 'bye~'
    })
  }
  setNum() {
    this.setState({
      num: 17
    })
  }
  render() {
    return (
      <>
        <p>我是父组件</p>
        <button onClick={()=>this.setData()}>修改-data</button>
        <button onClick={()=>this.setNum()}>修改-num</button>
        <Son1 num={this.state.num}></Son1>
        <Son2 num={this.state.num}></Son2>
      </>
    );
  }
}

export default Father;
